package HomeWork;

class Solution2 {
    public int removeElement(int[] nums, int val) {
        if(nums == null)
            return 0;
        int ret = 0;
        for (int i = 0; i < nums.length; i++) {
            if(nums[i] != val) {
                nums[ret] = nums[i];
                ret++;
            }
        }
        return ret;
    }
}
public class Test_2 {
    public static void main(String[] args) {
        Solution2 s = new Solution2();
        int[] nums = {0,1,2,2,3,0,4,2};
        System.out.println(s.removeElement(nums, 2));
    }
}
